#!/bin/sh
hostname="192.168.137.183"
password="raspberry"

if [ $# = 1 ]; then
    hostname=$1
fi
if [ $# = 2 ]; then
    hostname=$1
    password=$2
fi

echo "hostname: ${hostname}"
echo "password: ${password}"

sshpass -p "${password}" ssh -o StrictHostKeyChecking=no cm5@"${hostname}" 'mkdir -p RflyPilot_Project/RflyPilot/'
sshpass -p "${password}" rsync -av -l ./rflypilot ../config/rflypilot.txt ../config/parameter.txt cm5@"${hostname}":/home/cm5/RflyPilot_Project/RflyPilot/
# sshpass -p "${password}" scp -r ./rflypilot ../config/rflypilot.txt ../config/calibration.txt ../config/parameter.txt pi@"${hostname}":/home/pi/RflyPilot_Project/RflyPilot/

# 上传动捕动态链接库
if sshpass -p "${password}" ssh -o StrictHostKeyChecking=no cm5@"${hostname}" "[ -d /home/cm5/RflyPilot_Project/LuMoSDK ]"; then
    echo "远程文件已存在，无需操作"
else
    sshpass -p "${password}" ssh -o StrictHostKeyChecking=no cm5@"${hostname}" 'mkdir -p RflyPilot_Project/LuMoSDK/'
    sshpass -p "${password}" rsync -av -l ../src/3rdparty/LuMoSDK/* cm5@"${hostname}":/home/cm5/RflyPilot_Project/LuMoSDK/
    # sshpass -p "${password}" ssh -o StrictHostKeyChecking=no cm5@"${hostname}" 'mv /home/cm5/RflyPilot_Project/LuMoSDK/lib/libprotobuf.so /home/cm5/RflyPilot_Project/LuMoSDK/lib/libprotobuf.so.29'
    # sshpass -p "${password}" ssh -o StrictHostKeyChecking=no cm5@"${hostname}" 'mv /home/cm5/RflyPilot_Project/LuMoSDK/lib/libzmq.so /home/cm5/RflyPilot_Project/LuMoSDK/lib/libzmq.so.5'

    # export LD_LIBRARY_PATH=/home/cm5/RflyPilot_Project/LuMoSDK/lib:$LD_LIBRARY_PATH
fi